import { _decorator, Node, Prefab, instantiate, ScrollView, UITransform } from 'cc';
import { App } from '../../App';
import UtilTool from '../../tools/UtilTool';
import AbstractComponent from '../../base/AbstractComponent';
import { EditBox } from 'cc';
import { showErrorTip, showTip } from '../../tools/PopuUp';
import CommConst from '../../const/CommConst';
import wsTool from '../../net/ws';
import { PD } from '../../player/PlayerData';
import { Component } from 'cc';
import { Sprite } from 'cc';
const { ccclass, property } = _decorator;

// 头像界面
@ccclass('HeadItem')
export class HeadItem extends Component {
    @property(Node)
    di: Node = null

    @property(Node)
    head: Node = null

    @property(Node)
    gou: Node = null

    parentObj = null
    headId = 0

    onLoad() {
    }

    start() {
        
    }

    setData(parentObj, headId) {
        this.parentObj = parentObj
        this.headId = headId

        let headDict = App.Scene.getHallRes("images/head")
        if (headDict["head_" + headId]) {
            this.head.getComponent(Sprite).spriteFrame = headDict["head_" + headId]
        }
    }

    /**
     * 设置选中头像
     * @param isSel 是否选中
     */
    setSelect(isSel) {
        this.di.active = isSel
        this.gou.active = isSel
    }

    // 点击头像
    onBtnSelect(){
        this.parentObj.selectHead(this)
    }

  

}

